const mysql = require('../db/mysql');

// 用户登录处理
const loginServer = async (params, sql) => {
    const result = await mysql.query(sql, params);
    return result;
}

// 检测用户是否存在
const checkUser = async (account) => {
    const sql = `SELECT * FROM users WHERE account = ?`;
    const params = [account];
    const result = await mysql.query(sql, params);
    return result.length > 0;
}

// 用户注册处理
const registerServer = async (params, sql) => {
    const result = await mysql.query(sql, params);
    console.log(result);
    return result.affectedRows > 0;
}

module.exports = {
    loginServer,
    checkUser,
    registerServer,
}